Page({
    data: {
      newPwd: '',
      confirmPwd: '',
      canSubmit: false
    },
  
    onNewPwdInput(e) {
      const value = e.detail.value;
      this.setData({
        newPwd: value
      });
      this.checkCanSubmit();
    },
  
    onConfirmPwdInput(e) {
      const value = e.detail.value;
      this.setData({
        confirmPwd: value
      });
      this.checkCanSubmit();
    },
  
    checkCanSubmit() {
      const { newPwd, confirmPwd } = this.data;
      // 简单校验：两次输入密码不为空且一致可提交
      const canSubmit = newPwd.trim()!== '' && confirmPwd.trim()!== '' && newPwd === confirmPwd;
      this.setData({
        canSubmit
      });
    },
  
    onConfirm() {
      const { newPwd, confirmPwd } = this.data;
      // 这里可添加与后端交互逻辑，比如调用接口修改密码
      // 示例：假设调用接口，实际需替换为真实接口及处理
      wx.showToast({
        title: '密码修改成功',
        icon: 'success',
        duration: 2000,
        success: () => {
          // 可根据需求，修改成功后返回上一页面等
          wx.navigateBack();
        }
      });
    }
  });